/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GerenciadorEventos.java
 *
 * Created on 28/05/2011, 11:47:18
 */
package gui;

import entidades.*;
import fachadas.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.JOptionPane;

/**
 *
 * @author Thiago
 */
public class GerenciadorEventos extends javax.swing.JFrame {

    UserInterfaceFacade gerEventos;

    /** Creates new form GerenciadorEventos */
    public GerenciadorEventos() {
        gerEventos = new UserInterfaceFacade();
        initComponents();
        setLocationRelativeTo(null);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jComboBox_Hora1 = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jButton_Salvar1 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jTextField_IdEvento = new javax.swing.JTextField();
        jTextField_NomeEvento = new javax.swing.JTextField();
        jTextField_ContatoEvento = new javax.swing.JTextField();
        jComboBox_NoRepeticoes = new javax.swing.JComboBox();
        jComboBox_DiaT = new javax.swing.JComboBox();
        jComboBox_AnoT = new javax.swing.JComboBox();
        jComboBox_Mes1 = new javax.swing.JComboBox();
        jComboBox_Dia1 = new javax.swing.JComboBox();
        jComboBox_MesT = new javax.swing.JComboBox();
        jComboBox_Ano = new javax.swing.JComboBox();
        jComboBox_HoraT = new javax.swing.JComboBox();
        jComboBox_Minuto = new javax.swing.JComboBox();
        jComboBox_Hora2 = new javax.swing.JComboBox();
        jComboBox_MinutoT = new javax.swing.JComboBox();
        jComboBox_AreaEvento = new javax.swing.JComboBox();
        jButton_CadastraEvento = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jTextField_CampoPesquisa = new javax.swing.JTextField();
        jButton_Pesquisa = new javax.swing.JButton();
        jButton_CancelaEvento = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jTextField_Search = new javax.swing.JTextField();
        jComboBox_ParametroPesquisa = new javax.swing.JComboBox();
        jButton_PesquisaEvento = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jButton_Salvar = new javax.swing.JButton();
        jButton_Voltar = new javax.swing.JButton();

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 440, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 262, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("tab1", jPanel2);

        jComboBox_Hora1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));

        jLabel9.setText("h");

        jLabel10.setText("h");

        jLabel11.setText("h");

        jButton_Salvar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/okIcon.png"))); // NOI18N
        jButton_Salvar1.setText("Salvar");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Id do Evento:");

        jLabel2.setText("Nome do Evento:");

        jLabel3.setText("Area do Evento:");

        jLabel4.setText("Contato:");

        jLabel5.setText("No de Repeticoes:");

        jLabel6.setText("Data do Inicio do Evento:");

        jLabel7.setText("Data do Termino do Evento:");

        jComboBox_NoRepeticoes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40" }));

        jComboBox_DiaT.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        jComboBox_AnoT.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030" }));

        jComboBox_Mes1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));

        jComboBox_Dia1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        jComboBox_MesT.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));

        jComboBox_Ano.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030" }));

        jComboBox_HoraT.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));

        jComboBox_Minuto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59" }));
        jComboBox_Minuto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	// Usa isso pra algo?
            }
        });

        jComboBox_Hora2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));

        jComboBox_MinutoT.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59" }));

        jComboBox_AreaEvento.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Biologia", "Fisica", "Quimica", "Computacao" }));

        jButton_CadastraEvento.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/okIcon.png"))); // NOI18N
        jButton_CadastraEvento.setText("Cadastrar");
        jButton_CadastraEvento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_CadastraEventoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField_IdEvento, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField_NomeEvento, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox_AreaEvento, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField_ContatoEvento, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox_NoRepeticoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addComponent(jComboBox_Dia1, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jComboBox_Mes1, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(jComboBox_Ano, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(42, 42, 42)
                .addComponent(jComboBox_Hora2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(jComboBox_Minuto, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jComboBox_DiaT, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(13, 13, 13)
                .addComponent(jComboBox_MesT, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(13, 13, 13)
                .addComponent(jComboBox_AnoT, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(40, 40, 40)
                .addComponent(jComboBox_HoraT, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(jComboBox_MinutoT, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(130, 130, 130)
                .addComponent(jButton_CadastraEvento, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextField_IdEvento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(jLabel1)))
                .addGap(10, 10, 10)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextField_NomeEvento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel2)))
                .addGap(10, 10, 10)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboBox_AreaEvento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addComponent(jLabel3)))
                .addGap(10, 10, 10)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextField_ContatoEvento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(7, 7, 7)
                        .addComponent(jLabel4)))
                .addGap(9, 9, 9)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboBox_NoRepeticoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(9, 9, 9)
                        .addComponent(jLabel5)))
                .addGap(18, 18, 18)
                .addComponent(jLabel6)
                .addGap(15, 15, 15)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jComboBox_Dia1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jComboBox_Mes1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jComboBox_Ano, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jComboBox_Hora2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox_Minuto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addComponent(jLabel7)
                .addGap(7, 7, 7)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboBox_DiaT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox_MesT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox_AnoT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox_HoraT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox_MinutoT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton_CadastraEvento)))
        );

        jTabbedPane2.addTab("Criar Evento", jPanel3);

        jLabel12.setText("Digite o Id do Evento a ser removido:");

        jButton_Pesquisa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/procuraIcon.png"))); // NOI18N
        jButton_Pesquisa.setText("Pesquisar Evento");
        jButton_Pesquisa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_PesquisaEventoActionPerformed(evt);
            }
        });

        jButton_CancelaEvento.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/exitIcon.png"))); // NOI18N
        jButton_CancelaEvento.setText("Cancelar Evento");
        jButton_CancelaEvento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_CancelaEventoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(75, 75, 75)
                .addComponent(jTextField_CampoPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 353, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(207, Short.MAX_VALUE))
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jButton_Pesquisa)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 272, Short.MAX_VALUE)
                .addComponent(jButton_CancelaEvento)
                .addGap(65, 65, 65))
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(355, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addComponent(jLabel12)
                .addGap(66, 66, 66)
                .addComponent(jTextField_CampoPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 114, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_Pesquisa)
                    .addComponent(jButton_CancelaEvento))
                .addGap(62, 62, 62))
        );

        jTabbedPane2.addTab("Cancelar Evento", jPanel4);

        jPanel5.setLayout(null);

        jLabel13.setText("Digite a chave da pesquisa e escolha o parÃ¢metro da pesquisa:");
        jPanel5.add(jLabel13);
        jLabel13.setBounds(30, 33, 302, 14);
        jPanel5.add(jTextField_Search);
        jTextField_Search.setBounds(30, 90, 272, 20);

        jComboBox_ParametroPesquisa.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Contato", "Horario", "Nome" }));
        jPanel5.add(jComboBox_ParametroPesquisa);
        jComboBox_ParametroPesquisa.setBounds(320, 90, 83, 20);

        jButton_PesquisaEvento.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/procuraIcon.png"))); // NOI18N
        jButton_PesquisaEvento.setText("Pesquisar Evento");
        jButton_PesquisaEvento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_PesquisaEventoActionPerformed(evt);
            }
        });
        jPanel5.add(jButton_PesquisaEvento);
        jButton_PesquisaEvento.setBounds(220, 170, 141, 29);

        jLabel14.setForeground(new java.awt.Color(204, 0, 0));
        jLabel14.setText("Para pesquisar pelo Horário, digite no formato dd/mm/aaaa hh:mm. Por exemplo 01/01/2011 00:00");
        jPanel5.add(jLabel14);
        jLabel14.setBounds(40, 60, 530, 14);

        jTabbedPane2.addTab("Localizar Evento", jPanel5);

        jButton_Salvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/okIcon.png"))); // NOI18N
        jButton_Salvar.setText("Salvar");

        jButton_Voltar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/backIcon.png"))); // NOI18N
        jButton_Voltar.setText("Voltar");
        jButton_Voltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_VoltarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton_Voltar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 424, Short.MAX_VALUE)
                .addComponent(jButton_Salvar)
                .addGap(32, 32, 32))
            .addComponent(jTabbedPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 640, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jTabbedPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_Salvar)
                    .addComponent(jButton_Voltar))
                .addGap(15, 15, 15))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton_VoltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_VoltarActionPerformed
        gerEventos.menuSair();
        new TelaPrincipal().setVisible(true);
        dispose();
    }//GEN-LAST:event_jButton_VoltarActionPerformed

    private void jButton_CancelaEventoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_CancelaEventoActionPerformed

        String msgErro = "";
        String idEventoCancelado = jTextField_CampoPesquisa.getText();

        if (textoEmBranco(idEventoCancelado)) {
            msgErro += "Id do Evento InvÃƒÂ¡lido\n";
        }

        if (!msgErro.isEmpty()) {
            JOptionPane.showMessageDialog(null, msgErro, "Erro em Cancelar Evento", JOptionPane.ERROR_MESSAGE);

        } else {

            try {
                gerEventos.cancelarEvento(idEventoCancelado);
                JOptionPane.showMessageDialog(null, "Evento Cancelado com Sucesso",
                        "Cancelar Evento", JOptionPane.OK_OPTION);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, msgErro + e.getMessage(),
                        "Erro em Cancelar Evento", JOptionPane.ERROR_MESSAGE);
            }
        }

        gerEventos.menuSair();

    }//GEN-LAST:event_jButton_CancelaEventoActionPerformed

    private void jButton_PesquisaEventoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_PesquisaEventoActionPerformed

        String msgErro = "";
        String eventoSelecionado = "";

        String eventoPesquisa = jTextField_Search.getText();

        if (textoEmBranco(eventoPesquisa)) {
            msgErro += "Campo de Pesquisa InvÃƒÂ¡lido\n";
        }

        String parametroPesquisa = jComboBox_ParametroPesquisa.getModel().getSelectedItem().toString();

        if (!msgErro.isEmpty()) {
            JOptionPane.showMessageDialog(null, "Verifique se esses campos foram\n"
                    + "preenchidos corretamente:\n\n" + msgErro,
                    "Erro Ao Pesquisar Evento", JOptionPane.ERROR_MESSAGE);
        } else {

            try {
                eventoSelecionado = localizaEvento(parametroPesquisa, eventoPesquisa);
                JOptionPane.showMessageDialog(null, eventoSelecionado,
                        "Pesquisa Evento", JOptionPane.OK_OPTION);

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Nenhum Evento Encontrado",
                        "Erro Ao Pesquisar Evento", JOptionPane.ERROR_MESSAGE);
            }

        }

    }//GEN-LAST:event_jButton_PesquisaEventoActionPerformed

    private void jButton_CadastraEventoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_CadastraEventoActionPerformed

        String msgErro = "";

        String idEvento = jTextField_IdEvento.getText();
        String nomeEvento = jTextField_NomeEvento.getText();
        String areaEvento = (String) jComboBox_AreaEvento.getSelectedItem();
        String contatoEvento = jTextField_ContatoEvento.getText();
        int repeticoes = Integer.parseInt(jComboBox_NoRepeticoes.getModel().getSelectedItem().toString());

        if (textoEmBranco(idEvento)) {
            msgErro += "Id do Evento InvÃ¡lido\n";
        }

        if (textoEmBranco(nomeEvento)) {
            msgErro += "Nome do Evento InvÃ¡lido\n";
        }

        if (textoEmBranco(areaEvento)) {
            msgErro += "Area do Evento InvÃ¡lido\n";
        }

        if (textoEmBranco(contatoEvento)) {
            msgErro += "Contato do Evento InvÃ¡lido\n";
        }

        String diaInicio = jComboBox_Dia1.getModel().getSelectedItem().toString();
        String mesInicio = jComboBox_Mes1.getModel().getSelectedItem().toString();
        String anoInicio = jComboBox_Ano.getModel().getSelectedItem().toString();

        String horaInicio = jComboBox_Hora2.getModel().getSelectedItem().toString();
        String minutoInicio = jComboBox_Minuto.getModel().getSelectedItem().toString();

        String diaTermino = jComboBox_DiaT.getModel().getSelectedItem().toString();
        String mesTermino = jComboBox_MesT.getModel().getSelectedItem().toString();
        String anoTermino = jComboBox_AnoT.getModel().getSelectedItem().toString();

        String horaTermino = jComboBox_HoraT.getModel().getSelectedItem().toString();
        String minutoTermino = jComboBox_MinutoT.getModel().getSelectedItem().toString();

        String dataInicio = diaInicio + "/" + mesInicio + "/" + anoInicio + " " + horaInicio + ":" + minutoInicio;
        String dataTermino = diaTermino + "/" + mesTermino + "/" + anoTermino + " " + horaTermino + ":" + minutoTermino;

        if (textoEmBranco(dataInicio)) {
            msgErro += "Data de InÃ­cio InvÃ¡lida\n";
        }

        if (textoEmBranco(dataTermino)) {
            msgErro += "Data de TÃ©rmino InvÃ¡lida\n";
        }

        if (!msgErro.isEmpty()) {
            JOptionPane.showMessageDialog(null, "Verifique se esses campos foram\n"
                    + "preenchidos corretamente:\n\n" + msgErro,
                    "Erro Ao Cadastrar", JOptionPane.ERROR_MESSAGE);

        } else {
            try {

                if (repeticoes == 0) {
                    gerEventos.adicionarEvento(idEvento, nomeEvento, dataInicio, dataTermino, areaEvento, contatoEvento);
                } else {
                    gerEventos.adicionarEvento(idEvento, nomeEvento, dataInicio, dataTermino, areaEvento, contatoEvento, repeticoes);
                }
                gerEventos.menuSair();

               JOptionPane.showMessageDialog(null, "Evento Cadastrado com Sucesso",
                        "Evento Cadastrado", JOptionPane.INFORMATION_MESSAGE);

            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, "Verifique se esses campos foram\n"
                        + "preenchidos corretamente:\n\n" + ex.getMessage(),
                        "Erro Ao Cadastrar", JOptionPane.ERROR_MESSAGE);
            }
        }

    }//GEN-LAST:event_jButton_CadastraEventoActionPerformed

    private void jButton_SalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_SalvarActionPerformed
        gerEventos.menuSair();
        JOptionPane.showMessageDialog(null, "ModificaÃƒÂ§ÃƒÂµes Salvas",
                "Salvar Gerenciador", JOptionPane.ERROR_MESSAGE);
        //gravaGerenciador
    }//GEN-LAST:event_jButton_SalvarActionPerformed

    private String localizaEvento(String parametro, String eventoPesquisado) throws Exception {
        List<Escalonavel> listaEscalonavel = gerEventos.getListaDeEventos();
        List<Evento> listaEventos = new ArrayList<Evento>();
        String saida = "";

        for (int i = 0; i < listaEscalonavel.size(); i++){
            listaEventos.add( (Evento) listaEscalonavel.get(i));
        }

        if (parametro.equalsIgnoreCase("Horario")) {
            for (int i = 0; i < listaEventos.size(); i++) {
                if (listaEventos.get(i).getInicio().equals(eventoPesquisado) ||
                        listaEventos.get(i).getFim().equals(eventoPesquisado)) {
                    saida += listaEventos.get(i).getId() + "\n";
                }
            
            }
        }

        if (parametro.equalsIgnoreCase("Contato")) {

            for (int i = 0; i < listaEventos.size(); i++) {
                if (listaEventos.get(i).getContato().equals(eventoPesquisado)) {
                    saida += listaEventos.get(i).getAtributo("Id") + "\n";
                }
            }

        }

        if (parametro.equalsIgnoreCase("Nome")) {

            for (int i = 0; i < listaEventos.size(); i++) {
                if (listaEventos.get(i).getNome().equals(eventoPesquisado)) {
                    saida += listaEventos.get(i).getId() + "\n";
                }
            }
        }

//        if (saida == null) {
//            return "Nenhum evento encontrado";
//        } else {
//            return saida;
//        }

        return (saida == null ? "Nenhum evento encontrado": saida);
        
    }

    private boolean textoEmBranco(String texto) {
        return (texto.replace(" ", "").equals(""));
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new GerenciadorEventos().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton_CadastraEvento;
    private javax.swing.JButton jButton_CancelaEvento;
    private javax.swing.JButton jButton_Pesquisa;
    private javax.swing.JButton jButton_PesquisaEvento;
    private javax.swing.JButton jButton_Salvar;
    private javax.swing.JButton jButton_Salvar1;
    private javax.swing.JButton jButton_Voltar;
    private javax.swing.JComboBox jComboBox_Ano;
    private javax.swing.JComboBox jComboBox_AnoT;
    private javax.swing.JComboBox jComboBox_AreaEvento;
    private javax.swing.JComboBox jComboBox_Dia1;
    private javax.swing.JComboBox jComboBox_DiaT;
    private javax.swing.JComboBox jComboBox_Hora1;
    private javax.swing.JComboBox jComboBox_Hora2;
    private javax.swing.JComboBox jComboBox_HoraT;
    private javax.swing.JComboBox jComboBox_Mes1;
    private javax.swing.JComboBox jComboBox_MesT;
    private javax.swing.JComboBox jComboBox_Minuto;
    private javax.swing.JComboBox jComboBox_MinutoT;
    private javax.swing.JComboBox jComboBox_NoRepeticoes;
    private javax.swing.JComboBox jComboBox_ParametroPesquisa;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTextField jTextField_CampoPesquisa;
    private javax.swing.JTextField jTextField_ContatoEvento;
    private javax.swing.JTextField jTextField_IdEvento;
    private javax.swing.JTextField jTextField_NomeEvento;
    private javax.swing.JTextField jTextField_Search;
    // End of variables declaration//GEN-END:variables
}